<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    p {
        width: 300px;
        height: 50px;
        background-color: pink;
        color: #fff;
    }
</style>
<body>
    <button class="btn">点击显示时间</button>
    <p>显示时间</p>
    <script>
        var btn = document.querySelector('.btn')
        var p = document.querySelector('p')
        btn.onclick = function(){
            p.innerText = '当前时间为' + new Date()
        }
    </script>
</body>
</html>